Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@csstools/selector-specificity

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/selector-specificity

Determine selector specificity with postcss-selector-parser

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.9M
increased by3.79%
Maintainers
2
Weekly downloads
 
Created

What is @csstools/selector-specificity?

@csstools/selector-specificity is an npm package designed to calculate the specificity of CSS selectors. This can be useful for developers who need to understand or manipulate the specificity of their CSS rules, ensuring that styles are applied as intended.

What are @csstools/selector-specificity's main functionalities?

Calculate Specificity

This feature allows you to calculate the specificity of a given CSS selector. The output is an object with properties 'a', 'b', and 'c' representing the specificity components.

const { calculate } = require('@csstools/selector-specificity');

const specificity = calculate('div.class#id');
console.log(specificity); // Output: { a: 1, b: 1, c: 1 }

Compare Specificity

This feature allows you to compare the specificity of two CSS selectors. The output is a number indicating which selector has higher specificity.

const { compare } = require('@csstools/selector-specificity');

const result = compare('div.class#id', 'div#id');
console.log(result); // Output: 1

Other packages similar to @csstools/selector-specificity

Keywords

FAQs

Package last updated on 21 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc